export default {
	printConfig(offset,width,height,maxheight,qty){
		/**
		 * offset 整个标签的横向偏置。此值可以使所有域以指定的单位数量进行横向偏置
		 * width 横向分辨率 （以点/英寸为单位）。
		 * height 纵向分辨率 （以点/英寸为单位）。
		 * maxheight 标签的最大高度
		 * qty 要打印的标签数量
		 * */
		 var config = "!"+ " "+ offset+ " "+ width+ " "+ height+ " "+ maxheight+ " "+ qty+"\r\n";
		 return config;
	},
	/**
	 * width 打印纸宽度
	 * */
	printWidth(width){
		 var config = "PAGE-WIDTH"+ " "+ width+"\r\n"; 
		 return config;
	},
	/**
	 * before 打印前走纸距离
	 * */
	printPrefeed(before){
		 var config = "PREFEED"+ " "+ before+"\r\n"; 
		 return config;
	},
	/**
	 * after 打印后走纸距离
	 * */
	printPostfeed(after){
		 var config = "POSTFEED"+ " "+ after+"\r\n"; 
		 return config;
	},
	/**
	 * 打印速度
	 * */
	printSpeed(s){
		var config = "SPEED" + " " + s + "\r\n";
		return config;
	},
	/**
	 * 数字自动增加
	 * */
	printCount(s){
		var config = "COUNT" + " " + s + "\r\n";
		return config;
	},
	/**
	 * 字符放大
	 * */
	printSetMag(w,h){
		var config = "SETMAG" + " " + w + " " + h + "\r\n";
		return config;
	},
	 
	printForm(){
		var text = "FORM\r\n";
		return text;
	},
	printEnd(){
		var text =  "END\r\n";
		return text;
	},
	print(){
		var text = "PRINT\r\n"
		return text;
	},
	/**
	 * c居中
	 * l居左
	 * r居右
	 * */
	printAlign(align){
		var text = ""
		if(align == 'c'){
			text = "CENTER\r\n"
		}else if(align == 'l'){
			text = "LEFT\r\n"
		}else if(align == 'r'){
			text = "RIGHT\r\n"
		}
		return text;
	},
	/**
	 * 加粗开始
	 * */
	printSetBoldStart(){
		var text = "SETBOLD 1\r\n"
		return text;
	},
	/**
	 * 加粗结束
	 * */
	printSetBoldEnd(){
		var text = "SETBOLD 0\r\n"
		return text;
	},
	
	/**
	 * command 打印方向=> T：横向 VT：逆时针90度，纵向 T90：同VT T180：逆时针180度，反正 T270：逆时针270度，纵向
	 * font 字体名称 1:24x24 ,2:24x24, 3:20x20, 4:32x32, 5:24x24, 7:24x24, 8:24x24, 20:16x16, 55:16x16, 28:28x28
	 * size 字体大小 
	 * x y 起始位置
	 * data 打印内容
	 * */
	printText(command,font,size,x,y,data){
		var text = command + " " + font + " " + size + " " + x + " " + y + " " + data + "\r\n";
		return text;
	},
	printBoxs: function(p, l, w, k, s) { //起点坐标、长高、宽、线宽、显示(上左下右)
		// {x:0,y:215},530,560,2,{t:true,l:true,b:true,r:true}
		var text = "";
		if (s.t) {
			text = text.concat("L ", p.x, " ", p.y, " ", w, " ", p.y, " ", k, "\r\n");
		}
		if (s.l) {
			text = text.concat("L ", p.x, " ", p.y, " ", p.x, " ", p.y+l, " ", k, "\r\n");
		}
		if (s.b) {
			text = text.concat("L ", p.x, " ", p.y+l, " ", w, " ", p.y+l, " ", k, "\r\n");
		}
		if (s.r) {
			text = text.concat("L ", w, " ", p.y+l, " ", w, " ", p.y, " ", k, "\r\n");
		}
		return text;
	},
	/**
	 * 边框
	 * x,y 起点
	 * w,h 终点
	 * s 宽度
	 * */
	printBox: function(x, y, w, h, s) {
		var text = "";
		text = text.concat("BOX ", x, " ",y, " ", w , " ", h, " ", s, "\r\n");
		return text;
	},
	/**
	 * command  LINE （或 L）： 打印线条。
	 * sx,sy 起点
	 * ex,ey 终点
	 * w 线宽度
	 * */
	printLine(sx,sy,ex,ey,w){
		var line = "L" + " " + sx + " " + sy + " " + ex + " " + ey + " " + w + "\r\n";
		return line;
	},
	
	/**
	 * 换行
	 * */
	cutLine: function(m,p, str) {//换行
		var r = "";
		var max = m;
		var n = parseInt(str.length / max);
		for (var i = 0; i < n; i++) {
			var temp = str.substr(i * max, max);
			r += "T 3 0 " + p.x + " " + (p.y + 40 * i) + " " + temp + "\r\n"
		}
		var w = str.substr(n * max);
		r += "T 3 0 " + p.x + " " + (p.y + 40 * n) + " " + w + "\r\n";
		return r;
	},
	cutLine270: function(m,p, str) {//换行
		var r = "";
		var max = m;
		var n = parseInt(str.length / max);
		for (var i = 0; i < n; i++) {
			var temp = str.substr(i * max, max);
			r += "T270 3 0 " + (p.x - 25 * i) + " " + p.y + " " + temp + "\r\n"
		}
		var w = str.substr(n * max);
		r += "T270 3 0 " + (p.x - 25 * n) + " " + p.y + " " + w + "\r\n";
		return r;
	},
	/**
	 * 打印数组数据
	 * */
	printLineList: function(p, list) {//打印数组数据
		var r = "";
		for (var i = 0; i < list.length&&i<5; i++) {
			r += "T 3 0 " + p.x + " " + (p.y + 40 * i) + " " + list[i] + "\r\n"
		}
		return r;
	},
	/**
	 * 打印数组数据 可换行
	 * */
	printLineList2: function(p, list) {//打印数组数据 可换行
		var r = "";
		for (var i = 0; i < list.length&&i<10; i=i+2) {
			r += "T 3 0 " + p.x + " " + (p.y + 60 * i) + " " + list[i] + "\r\n";
			if((i+1)<list.length){
				r += "T 3 0 " + (p.x+150) + " " + (p.y + 60 * i) + " " + list[i+1] + "\r\n";
			}
		}
		return r;
	},
	/**
	 * off true禁用
	 * font 字体号
	 * size 字体大小。
	 * offset 文本距离条码的单位偏移量。
	 * */
	printBarShow(off,font,size,offset){
		 var config ="";
		 if(off == true){
			config = "BT"+ " "+"OFF"+"\r\n"; 
			  
		 }else{
			config = "BT"+ " "+ font+ " "+ size+ " "+ offset.x+ " "+ offset.y + "\r\n"; 
		 }
		return config;
	},
	/**
	 * command  B横向 VB纵向
	 * type 类型
	 * width 窄条宽度 
	 * ratio 宽条与窄条比率
	 * height 条码高度
	 * x 横向起始位置
	 * y 纵向起始位置
	 * data 条码数据
	 * */
	printBar(command,type,width,ratio,height,x,y,data){
		var bar = command+ " "+ type+ " "+ width+ " "+ ratio+ " "+ height+ " "+ x+ " "+ y+ " "+ data+ "\r\n";
		return bar;
	},
	/**
	 * x 横向起始位置
	 * y 纵向起始位置
	 * m QR代码型号范围1-2
	 * u 高度/宽度的模块点数 值的范围1-32
	 * data QR条码数据
	 * */
	printQr(x,y,m,u,data){
		var qr = "";
		qr += "B QR"+ " "+ x + " "+ y + " "+ "M"+ " "+ m + " "+ "U"+ " "+ u+ "\r\n"; 
		qr += "MA,"+data+"\r\n";
		qr += "ENDQR\r\n";
		return qr;
	}
}